package com.example.qxfw.dysjrh.service.impl;

import com.example.qxfw.dysjrh.dto.RaideDto;
import com.example.qxfw.dysjrh.entity.RaidenData;
import com.example.qxfw.dysjrh.mapper.AdvNameMapper;
import com.example.qxfw.dysjrh.mapper.RaidenMapper;
import com.example.qxfw.dysjrh.service.RaidenService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@RequiredArgsConstructor
public class RaidenServiceImpl implements RaidenService {

    private final RaidenMapper raidenMapper;

    private final AdvNameMapper advNameMapper;

    @Override
    public List<RaideDto> getRaidenData(RaidenData raidenData) {
        //开始时间
        LocalDateTime startTime = raidenData.getStartTime();
        //结束时间
        LocalDateTime endTime = raidenData.getEndTime();
        //闪电定位仪
        String raidenType = raidenData.getLocaTetype();
        String advcode = raidenData.getAdvcode();

        String advName=advNameMapper.getcountByAdvcode(advcode);

//        switch (raidenType){
//            case "5":
//                return raidenMapper.getRaidenData(startTime,endTime);
//            case "9":
//                return raidenMapper.getRaidenData2(startTime,endTime);
//        }
//        return null;
        List<RaideDto> list = raidenMapper.getRaidenData(startTime, endTime, raidenType, advName);
        for (RaideDto raideDto : list) {
            raideDto.setAdvcode(advcode);
        }
        return list;
//        return raidenMapper.getRaidenData(startTime, endTime, raidenType,advName);

    }

}
